package com.likersai.funa.controller;

import com.likersai.funa.pojo.dto.req.customer.CustomerReq;
import com.likersai.funa.pojo.entity.Customer;
import com.likersai.funa.pojo.vo.model.Page;
import com.likersai.funa.pojo.vo.model.Result;
import com.likersai.funa.service.CustomerService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客户表(Customer)表控制层
 *
 * @author sun.ye
 * @since 2021-07-13 13:26:25
 */
@RestController
@RequestMapping("customer")
public class CustomerController {
    /**
     * 服务对象
     */
    @Resource
    private CustomerService customerService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Customer selectOne(Long id) {
        return this.customerService.queryById(id);
    }



    @PostMapping("queryPage")
    public Result<Page<Customer>> queryPage(@RequestBody CustomerReq param){
        Page<Customer>  result = customerService.queryPage(param);
        return Result.getSuccess(result);
    }


    @PostMapping("queryList")
    public Result<List<Customer>> queryList(@RequestBody CustomerReq param){
        List<Customer> result = customerService.queryList(param);
        return Result.getSuccess(result);
    }
}
